﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using NeoModulusBusinessRulesDLLBuilder.UserControls;

namespace NeoModulusBusinessRulesDLLBuilder.Dialogs
{
    public partial class OpenProjectWizard : Form
    {
        public string ProjectToOpen { get; set; }

        public OpenProjectWizard()
        {
            InitializeComponent();
        }

        private void btnOpenProject_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty((string)cbProjects.SelectedItem))
            {
                ProjectToOpen = (string)cbProjects.SelectedItem;
                this.DialogResult = DialogResult.Yes;
                this.Close();
            }
            else
            {
                this.DialogResult = DialogResult.Cancel;
                this.Close();
            }
        }

        private void OpenProjectWizard_Load(object sender, EventArgs e)
        {
            foreach(string project in Directory.EnumerateDirectories(ConfigurationManager.AppSettings[usrObjectTree.SAVELOCATION]))
            {
                cbProjects.Items.Add(project.Substring(project.LastIndexOf('\\')+1, project.Length - project.LastIndexOf('\\')-1));
            }
        }
    }
}
